We've explored the concept of string rotations before as garland words. Mathematically we can define them as a string s = uv is said to be a rotation of t if t = vu. For example, the string 0011001 is a rotation of 0100110, where u = 00110 and v = 01.
Today we're interested in lexicographically minimal string rotation or lexicographically least circular substring, the problem of finding the rotation of a string possessing the lowest lexicographical order of all such rotations. Finding the lexicographically minimal rotation is useful as a way of normalizing strings.
You'll be given strings, one per line.
Example: aabbccddbbaabb
Your program should solve the lexicographically minimal string rotation and produce the size of the substring to move and the resulting string.
Example: aabbaabbccddbb
Which is, in Python parlance:
"aabbccddbbaabb"[10:] + "aabbccddbbaabb"[:10]
onion
bbaaccaadd
alfalfa
weugweougewoiheew
pneumonoultramicroscopicsilicovolcanoconiosis
2 ionon
2 aaccaaddbb
6 aalfalf
14 eewweugweougewoih
12 amicroscopicsilicovolcanoconiosispneumonoultr
In [1]:
    
"aabbccddbbaabb"[10:] + "aabbccddbbaabb"[:10]
    
    Out[1]:
In [ ]: